/*
https://leetcode-cn.com/problems/er-jin-zhi-zhong-1de-ge-shu-lcof/solution/er-jin-zhi-zhong-1de-ge-shu-by-leetcode-50bb1/
 */
public class SolutionOffer15 {
    public int hammingWeight(int n) {
        int ans=0;
        while(n!=0){
            n&=n-1;
            ans++;
        }
        return ans;
    }

    public static void main(String[] args) {
        System.out.println(new SolutionOffer15().hammingWeight(-3));
    }
}
